package hc.bre.call


import hc.bre.ComponentConfig
import hc.bre.cmn.RuleDefinition
import hc.bre.cmn.struct.DataStruct
import hc.bre.cmn.RuleScriptBuilder

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class SqlQueryDefinition extends RuleDefinition {
	public static final ComponentConfig _config ;
	static {
		_config = new ComponentConfig();
		_config.rtype = 'rule:call:sqlquery';
		_config.rname = 'SQL查询';
		_config.builderClass = SqlQueryBuilder;
		_config.resultStruct = new hc.bre.call.SqlQueryStruct();
		_config.objectpage = '/rule/call/sqlqueryeditor.htm?rpath=${rpath}';
		_config.description = '''SqlQuery负责从关系数据库中检索信息。''';
	}

	Integer dataSource;
	String beforeQuery='';
	String afterQuery='';
	List<SqlQueryItem> list=[new SqlQueryItem().load(id:1,code:'sql',name:'sql')];

	@Override
	public SqlQueryDefinition load(Map map) {
		super.load(map);
		this.dataSource = map['dataSource'] as Integer;
		this.beforeQuery = map['beforeQuery'] ;
		this.afterQuery = map['afterQuery'] ;

		this.list = hc.Util.loadList(map['list'], SqlQueryItem.class)

		return this;
	}

//	@Override
//	public <T extends RuleScriptBuilder> Class<T> scriptBuilderClass() {
//		return SqlQueryBuilder.class;
//	}
}
